<template>
     <el-card class="page-container">
        <template #header>
            <div class="header">
                <span>修改密码</span>
            </div>
        </template>
        <el-row>
            <el-col :span="12">
                <el-form :model="params" :rules="rules" label-width="100px" size="large">
                    <el-form-item prop="old_pwd">
                        <el-input v-model="params.old_pwd" type="password" placeholder="请输入原密码" show-password></el-input>
                    </el-form-item>
                    <el-form-item prop="new_pwd">
                        <el-input v-model="params.new_pwd" type="password" placeholder="请输入原密码" show-password></el-input>
                    </el-form-item>
                    <el-form-item prop="re_pwd">
                        <el-input v-model="params.re_pwd" type="password" placeholder="请输入原密码" show-password></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="updatePwd">修改密码</el-button>
                        
                    </el-form-item>
                </el-form>
            </el-col>
        </el-row>
    </el-card>
</template>


<script setup>
import { ref } from 'vue'

const params = ref({
    old_pwd: '',
    new_pwd: '',
    re_pwd: ''
})
// const userInfo = ref({
//     id: 0,
//     username: 'zhangsan',
//     nickname: 'zs',
//     email: 'zs@163.com',
// })
const rules = {
    old_pwd: [
        { required: true, message: '请输入原密码', trigger: 'blur' },
        {
            pattern: /^\S{2,10}$/,
            message: '昵称必须是2-10位的非空字符串',
            trigger: 'blur'
        }
    ],
    new_pwd: [
        { required: true, message: '请输入新密码', trigger: 'blur' },
        {
            pattern: /^\S{2,10}$/,
            message: '昵称必须是2-10位的非空字符串',
            trigger: 'blur'
        }
    ],
    re_pwd: [
        { required: true, message: '请再次输入新密码', trigger: 'blur' },
        {
            pattern: /^\S{2,10}$/,
            message: '昵称必须是2-10位的非空字符串',
            trigger: 'blur'
        }
    ]
}

// import userUserInfoStore from '@/stores/userInfo';
import { userInfoResetPassword } from '@/api/user';
import { ElMessage } from 'element-plus';

// const userInfoStore = userUserInfoStore();
// const userInfo = ref({...userInfoStore.info})

async function updatePwd(){
    // // 扩展id属性
    // params.value
    let result = await userInfoResetPassword(params.value);
    ElMessage.success(result.data.message ? result.data.message :'成功修改密码');
}
// function show(){
//     // console.log('show函数展示params和userInfo')
//     // console.log(params.value);
//     // console.log(userInfo.value);
//     // console.log(userInfo.value.id);

// }
</script>

<!-- <template>修改密码</template> -->